package com.biz.primus.ms.oms.api;

import com.biz.primus.base.vo.PageResult;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.oms.vo.*;
import com.biz.primus.ms.oms.service.collection.OmsCollectionService;
import com.biz.primus.ms.oms.service.core.OrderQueryService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yanweijin
 * @date 2017/10/31
 */
@RestController
@RequestMapping("soa/oms")
public class OmsApiController {


	@Autowired
	private OmsCollectionService omsCollectionService;

	@Autowired
	private OrderQueryService orderQueryService;

	@PostMapping("pushOrder")
	@ApiOperation("HTTP推单接口")
	public void pushOrder(@RequestBody OmsOrderVo order){
		omsCollectionService.collectionOrder(order);
	}

	@PostMapping("getOrderHistoryByUserId")
	@ApiOperation("根据会员ID查询历史订单信息")
	public OmsOrderHistoryVo getOrderHistoryByUserId(@RequestBody OrderQueryVo orderQueryVo){
		return orderQueryService.getOrderHistoryInfoByUserId(orderQueryVo);
	}

	@PostMapping("getOrderProductByUserId")
	@ApiOperation("根据会员ID查询历史订单商品")
	public PageResult<OmsHistoryOrderProductVo> getOrderProductByUserId(@RequestBody  OrderQueryVo orderQueryVo){
		return orderQueryService.getOrderProductByUserId(orderQueryVo);
	}

	@PostMapping("getOrderByUserId")
	@ApiOperation("根据用户ID分页查询订单列表")
	public PageResult<OmsOrderVo> getOrderByUserId(@RequestBody  OrderQueryVo orderQueryVo){
		return orderQueryService.managementOrderQuery(orderQueryVo);
	}

	@GetMapping("getOrderDetail")
	@ApiOperation("获取订单详情信息")
	public OmsOrderRespVo getOrderDetail(@ApiParam(value = "订单编码", required = true) @RequestParam("orderCode")
												 String orderCode){
		return orderQueryService.getOrderDetail(orderCode);
	}
}
